package com.ruoyi.coupons.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.coupons.domain.Coupon;
import com.ruoyi.coupons.service.CouponService;
import com.ruoyi.coupons.mapper.CouponMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author a'su's
* @description 针对表【coupon(优惠券表)】的数据库操作Service实现
* @createDate 2025-03-18 11:06:04
*/
@Service
public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon>
    implements CouponService{

    @Autowired
    private CouponMapper couponMapper;

    @Override
    public int getLimit(int couponId) {

        return couponMapper.getLimit(couponId).getLimitPerPerson();
    }

    @Override
    public int decreaseStock(int couponId) {
        return couponMapper.decreaseStock(couponId);
    }

    @Override
    public int getStock(int couponId) {
        return couponMapper.getLimit(couponId).getInventory();
    }
}




